using System.Windows.Forms;
using SpreadsheetGear;
using SpreadsheetGear.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using WorkbookDesigner.Main;
using DesignerHelper.Main;

namespace WorkbookDesigner.Addons.WorkbookExplorer
{
    internal class UcFactory
    {
        internal UcFactory(IList<IBookForm> viewList)
        {
            BookSetOptions = new WorkbookSetOptions() {Dock = DockStyle.Fill};
            InitBt = new BaseTabFactory();
            ViewList = viewList;
        }

        internal WorkbookSetOptions BookSetOptions { get; }
        private BaseTabFactory InitBt { get; }
        private IList<IBookForm> ViewList { get; }

        internal BaseTab GetBaseTab(IWorkbook workbook)
        {
            WorkbookView wbv = ViewList.Select(x => x.WorkbookView).First(x => x.ActiveWorkbook == workbook);
            InitBt.Init(wbv);
            return InitBt.GetBaseTab();
        }

        internal BaseTab GetBaseTab(IWorksheet worksheet)
        {
            //WorkbookView wbv = FormManager.ViewList.Find(x => x.ActiveWorkbook.Worksheets.Contains(worksheet));
            InitBt.Init(worksheet); //bug 

            return InitBt.GetBaseTab();
        }
    }
}